const app = getApp();
Page({
    data: {
        CouponsList:[],
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
        TabbarBot: app.globalData.tabbar_bottom,
        TabCur: 1,scrollLeft:0,
        SortMenu: [{id:1,name:"未使用"},{id:2,name:"已使用"},{id:3,name:"已过期"}],
    },
    onLoad: function (options) {
        let _this = this;
        _this.couponList()
    },
    tabSelect(e) {
        console.log(e.currentTarget.dataset.id);
        this.setData({
            TabCur: e.currentTarget.dataset.id,
            scrollLeft: (e.currentTarget.dataset.id-1)*60
        })
        this.couponList()
    },
    couponList:function(){
      let _this = this
      wx.getStorage({
        key:'user',
        success:(res) => {
          wx.request({
            method:'GET',
            url: 'http://localhost:8989/coupons/state',
            data:{
              uid: res.data.uid,
              state: _this.data.TabCur
            },
            success:(res) =>{
              console.log(res.data.data)
              _this.setData({
                CouponsList:res.data.data
              })
            }
          })
        }
      })
    }
});
